Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
Does "return await" makes any difference?

Is there any difference between

const foo = async () => {
  // some other code that uses await
  return await bar()
}

and

const foo = async () => {
  // some other code that uses await
  return bar()
}

Where bar is a function that returns a promise.

Is the await redundant or does it make any difference?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

It is redundant.

It extracts the value from the promise returned by bar, and then resolves the promise returned by foo with it.

If you return bar's promise directly, then the promise returned by foo adopts it to the same effect.

about 4 years ago · Juan Pablo Isaza Denunciar

0

If the Promise is rejected, the error would be thrown in different places, in the two example you wrote.

In the first, a rejected error would happen inside foo.

In the second, a rejected error would happen to the function that called foo

about 4 years ago · Juan Pablo Isaza Denunciar

0

Yes.

If the function bar() returns a Promise, in the second case foo will return a pending Promise (a Promise that has not yet resolved). In the first case, foo will return the data the Promise resolved with after waiting for the Promise to resolve

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda